<?php
require_once "checklogin.php";
require_once "../lib/MySQLDB.class.php";
date_default_timezone_set('PRC');
$db=MySQLDB::getInstance();
if(!empty($_POST)){
    $data=$_POST;
    unset($data["imgfile"]);
    $data['newsPicKey']=isset($data["newsPicKey"])?1:'';
    $sql="insert into newsinfo 
      (newsCID,newsTitle,newsKeyWord,newsDesc,newsRemark,newsEditor,newsDate,newsPicUrl,newsContent,
      newsPicKey) values (?,?,?,?,?,?,?,?,?,?)";
    $res=$db->query($sql,"sssssssssi",$data);
    if($res){
        layerAlert("文章添加成功！",1,"newsList.php");
    }else{
        layerAlert("文章添加失败！",5,"newsAdd.php");
    }
}else{
    $sql="select * from category";
    $rows=$db->fetchAll($sql);
    $cateArr=getSubTree($rows,0,0);
    require_once "view/newsAdd.html";
}